<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ include file="/taglibs.jsp"%>
<link rel="stylesheet" href="/css/jquery.tooltip.css" />
<script src="/js/jquery.tooltip.min.js" type="text/javascript"></script>
<script language="javascript">
	$().ready(function(){
		$("tr[id*='tdDesc_']").tooltip();
	});
	
<yaodian100:checkPermission permissions="OTHER_TUANGOU">
<c-rt:if test="${(product.productType==0 || product.productType==1 || product.productType==7) && product.isDelete=='N'}">
	$().ready(function(){
		$("tr[id*='tdTip_']").tooltip();
		
		$("#loadingImg").dialog({
			bgiframe:true,
			modal:true,
			autoOpen:false
		});
		
		$("#editTuangouDescWindow").dialog({
			title:'编辑团购说明',
			width:450,
			height:220,
			bgiframe:true,
			modal:true,
			autoOpen:false,
			close: function(){
				
			}
		});
		
		$("#queryOrderOperatorWindow").dialog({
			title:'订单操作记录',
			width:450,
			bgiframe:true,
			modal:true,
			autoOpen:false,
			close: function(){
				
			}
		});
		
		$("#saveTuangouDescBtn").click(function(){
			saveTuangouDesc($("#tuangouIdFlg").attr("value"));
		});
	});
	
	function editTuangouDesc(tuangouId){
		$("#tuangouIdFlg").attr("value",tuangouId);
		$("#msgSpan").html("");
		
		var loadingDialog=$("#loadingImg");
		var editTuangouDescWindow=$("#editTuangouDescWindow");
		
		loadingDialog.dialog('open');
		$.post("<%=ServerValue.getMidContextPath()%>/shelf2/editTuangouDesc.do",
			{tuangouId:tuangouId},
			function(mapJson){
				loadingDialog.dialog('close');
				editTuangouDescWindow.dialog('open');
				if(null!=mapJson){
					$("#tuangouDesc").attr("value",mapJson.tuangouDesc);
				}
			},
			"json"
		);
	}
	
	function saveTuangouDesc(tuangouId){
		$("#msgSpan").html("");
		
		var loadingDialog=$("#loadingImg");
		var editTuangouDescWindow=$("#editTuangouDescWindow");
		
		loadingDialog.dialog('open');
		$.post("<%=ServerValue.getMidContextPath()%>/shelf2/saveTuangouDesc.do",
			{tuangouId:tuangouId,tuangouDesc:$("#tuangouDesc").val()},
			function(mapJson){
				loadingDialog.dialog('close');
				editTuangouDescWindow.dialog('open');
				$("#msgSpan").html(mapJson.saveMsg);
			},
			"json"
		);
	}
	
	function queryOrderOperator(tuangouId){
		var loadingDialog=$("#loadingImg");
		var queryOrderOperatorWindow=$("#queryOrderOperatorWindow");
		
		loadingDialog.dialog('open');
		$.post("<%=ServerValue.getMidContextPath()%>/shelf2/queryOrderOperator.do",
			{tuangouId:tuangouId},
			function(mapJson){
				loadingDialog.dialog('close');
				queryOrderOperatorWindow.dialog('open');
				if(null!=mapJson){
					$("#trTag").html("<td>"+mapJson.createUser+"</td><td>"+mapJson.operatorDesc+"</td><td>"+mapJson.createDate+"</td>");
				}else{
					$("#trTag").html("<td colspan='3'>查无资料</td>");
				}
			},
			"json"
		);
	}
</c-rt:if>
</yaodian100:checkPermission>
</script>

<style type="text/css">
    .bg-active {
        background: #D4FAED;
    }
</style>
<h1>商品管理 - 商品上下架<br/>
	
</h1>
<div class="f-link">
	<a href="<%=ServerValue.getFrontHostname()+ServerValue.getFrontContextPath()%>/product/productPreview.do?productId=${productId}" target="_blank">商品预览</a>
	<a href="add.do?productId=${productId}">新增上下架</a>
	<yaodian100:checkPermission permissions="OTHER_TUANGOU">
	<a href="addTuangou.do?productId=${productId}">新增团购卖场</a>
	<a href="listTuangou.do">团购商品列表页</a>
	</yaodian100:checkPermission>
	<a href="<%=ServerValue.getMidContextPath()%>/product2/list.do">回商品列表页</a>
</div>
<c-rt:if test="${not empty product.productId}">
	<jsp:include page="/WEB-INF/jsp/product/commonMenu2.jsp"/>
</c-rt:if>	
<style type="text/css">
.msg{float:left; line-height:1em; margin:0; display:block;border:1px solid #f66;padding:2px 5px;*padding:2px 5px 1px;}
.msg.rn{background-color:#fff2f2;border-color:#f66;}
</style>
<s:if test="hasActionErrors()">
	<s:actionerror cssClass="msg rn"/>
</s:if>
<s:if test="hasActionMessages()">
	<s:actionmessage cssClass="msg rn"/>
</s:if>
<s:if test="hasFieldErrors()">
	<s:fielderror cssClass="msg rn"/>
</s:if>
<div class="data-form">
	<s:form action="list.do" method="post">
		<b>狀態：</b>
	  <s:select name="shelfStatusParam" list="shelfQueryStatusMenu.options" listKey="key"  listValue="value.name"/>
	  <input type="hidden" name="productId" value="${product.productId}"/>		
		<input type="button" value="搜寻" onclick="this.form.submit();" />
		<font color="red">※有效(已审核、申请中)、无效(下架、审核失败)</font>
	</s:form>
</div>
<table class="tb-data" width="100%">
	<tr>
		<th>商品名称（商品编号）</th>
	</tr>
	<tr>
		<td>${productName}(${productId})</td>
	</tr>
</table>
<br/>注：以下蓝色文字为上架中
<s:form action="delShelf.do" method="post" id="productForm">
<table class="tb-1" width="100%">
	<thead>
		<tr>
      <th>下架</th>
			<th>上架状态</th>
			<th>商品促销小标</th>
			<th>上架起始日期时间</th>
			<th>上架结束日期时间</th>
			<th>最后修改日期</th>
			<th>上架售价</th>
			<th>操作</th>
		</tr>
	</thead>
	<tbody>
			<c-rt:forEach items="${shelfs}" var="shelf" varStatus="rows_index"> 
					<tr class="${shelfNow.shelfId == shelf.shelfId? 'bg-active' : ''}" id="tdDesc_${rows_index.count}" title="建立者:${shelf.createUser} 建立日期:${shelf.createDate}<br/>修改者:${shelf.modifyUser} 修改日期:${shelf.modifyDate}">
						<c-rt:choose>
					        <c-rt:when test="${shelf.shelfStatus ne 'SHF700'}">
					        	<td><input name="shelfDelete" type="checkbox" value="${shelf.shelfId}" /></td>
					        </c-rt:when>
					        <c-rt:otherwise><td></td></c-rt:otherwise>
				        </c-rt:choose>
						<td>${shelfStatusMenu.options[shelf.shelfStatus].name}</td>
						<td>${shelf.promoteName}</td>
						<td><fmt:formatDate value="${shelf.startDate}"
							pattern="yyyy-MM-dd HH:mm" /></td>
						<td><fmt:formatDate value="${shelf.endDate}"
							pattern="yyyy-MM-dd HH:mm" /></td>
							<td><fmt:formatDate value='${shelf.modifyDate}' pattern='yyyy-MM-dd' /> <fmt:formatDate value='${shelf.modifyDate}' pattern='HH:mm' /></td>
						<td><fmt-rt:formatNumber value="${shelf.shelfPrice}" pattern="#####0.0"/></td>
						<td>
							<c-rt:if test="${shelf.shelfStatus eq 'SHF000' or shelf.shelfStatus eq 'SHF500'}">
								<a href="<%=ServerValue.getMidContextPath()%>/shelf2/edit.do?shelfId=${shelf.shelfId}&productId=${shelf.productId}" />编辑</a>
							</c-rt:if>
						</td>
			 		 </tr> 
			</c-rt:forEach>
	</tbody>
</table>
<c-rt:if test="${not empty shelfs}">
<br />
<input type="submit" value="商品批次下架"/>
</c-rt:if>
	<div class="f-link">
		<a href="<%=ServerValue.getFrontHostname()+ServerValue.getFrontContextPath()%>/product/productPreview.do?productId=${productId}" target="_blank">商品预览</a>
		<a href="add.do?productId=${productId}">新增上下架</a>
		<yaodian100:checkPermission permissions="OTHER_TUANGOU">
			<a href="addTuangou.do?productId=${productId}">新增团购卖场</a>
			<a href="listTuangou.do">团购商品列表页</a>
		</yaodian100:checkPermission>
		<a href="<%=ServerValue.getMidContextPath()%>/product2/list.do">回商品列表页</a>
	</div>
<yaodian100:pageutil link="list.do" pagerObj="${pager}" />
</s:form>

<br />
<a href="<%=ServerValue.getMidContextPath()%>/image2/edit.do?productId=${product.productId}">< 返回上一步</a>